<?php

namespace App\Http\Controllers\Api\Website;

use  App\Http\Resources\WebSite\WorkshopCollection;
use App\Http\Resources\WorkShopResource;
use App\Interfaces\WorkshopInterFace;
use App\model\Workshop;
use App\Repository\WorkShopRepository;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
use Carbon\Carbon;
use App\BrowseRecords;
use App\UserSearch;
use App\model\ImSet;

class WorkshopController extends Controller
{
    public function index(Request $request,WorkshopInterFace $workShopRepository){


        $user_id = auth('api')->id();
      /*  if(isset($request['search_key'])&&$request['search_key']!=''&&isset($user_id)){
            $now = Carbon::now();
            UserSearch::updateOrCreate(['user_id'=>$user_id,'search_key'=>$request['search_key']],['updated_at'=>$now]);
        }*/
        $workShopList=$workShopRepository->DiskSourceList($request);
        return new WorkShopCollection($workShopList);
    }
    public function workshopRecommend(WorkshopInterFace $workshopInterFace){
        $workshop= $workshopInterFace->workshopRecommd(10);
        return new WorkshopCollection($workshop);
    }
    public function detail($workshop_id,WorkShopRepository $workShopRepository){
        $workshop=$workShopRepository->detail($workshop_id);

        return new  WorkShopResource($workshop);
    }
}
